package com.valsong.sandbox.mock;

import com.google.inject.AbstractModule;
import com.google.inject.name.Names;
import com.valsong.sandbox.mock.context.InternalBeforeAdviceListenerProvider;
import com.valsong.sandbox.mock.context.InternalEventWatcherContext;
import com.valsong.sandbox.mock.context.InternalEventWatcherProvider;
import com.valsong.sandbox.mock.filter.FacadeMockFilter;
import com.valsong.sandbox.mock.invoker.GroovyFileInvoker;
import com.valsong.sandbox.mock.logger.LogbackAdjustment;
import com.valsong.sandbox.mock.repository.JsonMockConfigRepository;


/**
 * GuiceBeanModule
 *
 * @author Val Song
 */
public class GuiceBeanModule extends AbstractModule {

    @Override
    public void configure() {

        bind(EventWatcherContext.class)
                .to(InternalEventWatcherContext.class)
                .asEagerSingleton();

        bind(MockFilter.class)
                .annotatedWith(Names.named("facadeMockFilter"))
                .to(FacadeMockFilter.class)
                .asEagerSingleton();

        bind(MockConfigRepository.class)
                .to(JsonMockConfigRepository.class)
                .asEagerSingleton();

        bind(Invoker.class)
                .annotatedWith(Names.named("groovyFileInvoker"))
                .to(GroovyFileInvoker.class)
                .asEagerSingleton();


        bind(AdviceListenerProvider.class)
                .to(InternalBeforeAdviceListenerProvider.class)
                .asEagerSingleton();

        bind(EventWatcherProvider.class)
                .to(InternalEventWatcherProvider.class)
                .asEagerSingleton();

        bind(LoggerAdjustment.class)
                .to(LogbackAdjustment.class)
                .asEagerSingleton();


    }
}
